<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>默认参数（实例2）</title>
</head>

<body>
    <p>设置函数参数默认值。</p>
    <p id="demo"></p>
    <script>
        function myFunction(x, y) {
            y = y || 0;
            return x * y;
        }
        document.getElementById("demo").innerHTML = myFunction(4);
    </script>
</body>

</html>